import { useState, useEffect } from "react";
import { invokeAsyncAPi } from "@/xz-fn.js";
function useLocalModel() {
  const [localModelList, setLocalModelList] = useState([]);
  const [localmodelName, setLocalModelName] = useState("");
  useEffect(() => {
    try {
      invokeAsyncAPi("xz_get_ai_model_list").then((res) => {
        const modelList =
          res.map((item) => ({
            value: item.name,
            label: item.name,
          })) || [];
        setLocalModelList(modelList);
        setLocalModelName(modelList[0]?.value);
        console.log("获取本地模型ddddd列表", modelList);
      });
      // 处理模型列表数据
    } catch (error) {
      console.error(error);
    }
  }, []);
  return { localModelList, localmodelName };
}
export default useLocalModel;
